home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------------
- File: PaletteExt.cpp
-
- Contains: Palette Extension implementation
-
- Written by: Sue Dumont, Andrey Dolgachev
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- ------------------------------------------------------------------------------*/
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- #ifndef _ODNEW_
- #include <ODNew.h>
- #endif
-
- #ifndef _ODNEWOBJ_
- #include <ODNewObj.h>
- #endif
-
- // Notification that this is a SOM source file
- #define Samples_PaletteExt_Class_Source
-
- // define underscore field names (ie. _fSelf)
- #define VARIABLE_MACROS
-
- // -- PaletteExt Includes --
-
- #ifndef SOM_Samples_PaletteExt_xih
- #include "PaletteExt.xih"
- #endif
-
- // Needs to be customized for the specific owner part.
- #ifndef SOM_SampleCode_ScriptRunner_xh
- #include "ScriptRunner.xh"
- #endif
-
- // -- OpenDoc Includes --
-
- #ifndef SOM_ODExtension_xh
- #include <Extensn.xh>
- #endif
-
-
- #pragma segment PaletteExt
-
- //====================================================================
- // PaletteExt - Common extension methods
- //====================================================================
-
- //------------------------------------------------------------------------------
- // Method: somInit
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK PaletteExt__somInit(Samples_PaletteExt *somSelf)
- {
- Samples_PaletteExtMethodDebug("PaletteExt","somInit");
-
- // somInit and somUninit methods behave like C++ constructors in that the
- // inherited methods are called automatically.
- // Thus, there is no need to call the parent class' somInit or somUninit.
-
- // There is also no need to set instance variables to zero/NULL
- // since SOM guarantees that a newly constructed object is zeroed.
- }
-
- //------------------------------------------------------------------------------
- // Method: somUninit
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK PaletteExt__somUninit(Samples_PaletteExt *somSelf)
- {
- Samples_PaletteExtMethodDebug("PaletteExt","somUninit");
- }
-
- //------------------------------------------------------------------------------
- // Method: Acquire
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK PaletteExt__Acquire(Samples_PaletteExt *somSelf, Environment *ev)
- {
- Samples_PaletteExtMethodDebug("PaletteExt","PaletteExt__Acquire");
-
- SOM_TRY
- Samples_PaletteExt_parent_ODExtension_Acquire(somSelf, ev);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: Release
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK PaletteExt__Release(Samples_PaletteExt *somSelf, Environment *ev)
- {
- Samples_PaletteExtMethodDebug("PaletteExt","Release");
-
- SOM_TRY
- Samples_PaletteExt_parent_ODExtension_Release(somSelf, ev);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: InitExtension
- //
- // Description:
- //------------------------------------------------------------------------------
- SOM_Scope void SOMLINK PaletteExt__InitExtension(Samples_PaletteExt *somSelf,
- Environment *ev, ODObject* base)
- {
- Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
- Samples_PaletteExtMethodDebug("PaletteExt","InitExtension");
-
- SOM_TRY
- Samples_PaletteExt_parent_ODExtension_InitExtension(somSelf, ev, base);
-
- _fOwner = (SampleCode_ScriptRunner*) ((ODPart*)base)->GetRealPart(ev);
- ((ODPart*)base)->ReleaseRealPart(ev);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: Show
- //
- // Description: Tell the owner part to show the palette.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK PaletteExt__Show(Samples_PaletteExt *somSelf, Environment *ev)
- {
- Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
- Samples_PaletteExtMethodDebug("PaletteExt","Show");
-
- SOM_TRY
- _fOwner->ShowPalette(ev);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: Hide
- //
- // Description: Tell the owner part to hide the palette.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK PaletteExt__Hide(Samples_PaletteExt *somSelf, Environment *ev)
- {
- Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
- Samples_PaletteExtMethodDebug("PaletteExt","Hide");
-
- SOM_TRY
- _fOwner->HidePalette(ev);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-
- //------------------------------------------------------------------------------
- // Method: IsPaletteVisible
- //
- // Description: Call the owner part to determine whether the palette
- // is visible or not, and return the result.
- //------------------------------------------------------------------------------
- SOM_Scope ODBoolean
- SOMLINK PaletteExt__IsPaletteVisible(Samples_PaletteExt *somSelf, Environment *ev)
- {
- Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
- Samples_PaletteExtMethodDebug("PaletteExt","IsPaletteVisible");
-
- ODBoolean result;
-
- SOM_TRY
- result = _fOwner->IsPaletteVisible(ev);
- SOM_CATCH_ALL
- result = kODFalse;
- SOM_ENDTRY
-
- return result;
- }
-
- //------------------------------------------------------------------------------
- // Method: Move
- //
- // Description: The corresponding method of the owner part is called to move
- // the palette to the specified top-left coordinate.
- // The result indicates whether the move was successful or not.
- //------------------------------------------------------------------------------
- SOM_Scope ODBoolean
- SOMLINK PaletteExt__Move(Samples_PaletteExt *somSelf, Environment *ev,
- ODPoint* topleft)
- {
- Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
- Samples_PaletteExtMethodDebug("PaletteExt","Move");
-
- ODBoolean result;
-
- SOM_TRY
- result = _fOwner->MovePalette(ev, topleft);
- SOM_CATCH_ALL
- result = kODFalse;
- SOM_ENDTRY
-
- return result;
- }
-
- //------------------------------------------------------------------------------
- // Method: GetLocation
- //
- // Description: This method calls the owner part to obtain the top-left
- // coordinate of the scripting palette.
- //------------------------------------------------------------------------------
- SOM_Scope ODPoint*
- SOMLINK PaletteExt__GetLocation(Samples_PaletteExt *somSelf,Environment *ev)
- {
- Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
- Samples_PaletteExtMethodDebug("PaletteExt","GetLocation");
-
- ODPoint* point;
-
- SOM_TRY
- point = _fOwner->GetPaletteLocation(ev);
- SOM_CATCH_ALL
- point = kODNULL;
- SOM_ENDTRY
-
- return point;
- }
-
- //------------------------------------------------------------------------------
- // Method: SetClient
- //
- // Description: This method is called by the client part when switching
- // from one part to another part of its own kind. It is
- // necessary to call this method to allow the sharing of
- // the palette window.
- //------------------------------------------------------------------------------
- SOM_Scope void
- SOMLINK PaletteExt__SetClient(Samples_PaletteExt *somSelf,
- Environment *ev, ODPart* client)
- {
- Samples_PaletteExtData *somThis = Samples_PaletteExtGetData(somSelf);
- Samples_PaletteExtMethodDebug("PaletteExt","PaletteExt__SetClient");
-
- SOM_TRY
- _fOwner->SetClient(ev, client);
- SOM_CATCH_ALL
- SOM_ENDTRY
- }
-